#ifndef __LONGGUI_CTRL_CLASS_H_
#define __LONGGUI_CTRL_CLASS_H_

#define MAXLEN_CLASSNAME    15

typedef struct _CTRLCLASSINFO
{
    char      name[MAXLEN_CLASSNAME + 1];
                                // class name
    /*
     * common properties of this class
     */
    DWORD     dwStyle;          // Default control styles.

    int (*ControlProc)(HWND, int, WPARAM, LPARAM);
                                // control procedure.

    int nUseCount;              // use count.
    struct _CTRLCLASSINFO*  next;
 }CTRLCLASSINFO;

typedef CTRLCLASSINFO* PCTRLCLASSINFO;

typedef struct tagCONTROL
{
    /*
     * These fields are similiar with MAINWIN struct.
     */
    short DataType;         // the data type
    short WinType;          // the window type

    int x;
    int y;
    int width;
    int height;
    DWORD dwStyle;          // the styles of child window.

    int (*ControlProc) (HWND, int, WPARAM, LPARAM);

    PZORDERNODE pZOrderNode;

    char* spCaption;         // the caption of control.
    int   id;                // the identifier of child window.

    PMAINWIN pMainWin;       // the main window that contains this control.

    struct tagCONTROL* pParent;// the parent of this control.
    /*
     * Child windows.
     */
    struct tagCONTROL* children;

    /*
     * The following members are only implemented for control.
     */
    struct tagCONTROL* next;   // the next sibling control.
    struct tagCONTROL* prev;   // the prev sibling control.
    PCTRLCLASSINFO pcci;     // pointer to Control Class Info struct.
}CONTROL;
typedef CONTROL* PCONTROL;


/* Function definitions */
#ifdef __cplusplus
extern "C" {
#endif  /* __cplusplus */

BOOL InitControlClass (void);
void TerminateControlClass (void);

PCTRLCLASSINFO GetControlClassInfo (const char* szClassName);

int AddNewControlClass (PWNDCLASS pWndClass);
int DeleteControlClass (const char* szClassName);
void EmptyControlClassInfoTable (void);

PCONTROL Control (HWND hWnd);   // check whether hWnd is control
                                // and return pointer to control hWnd.

#ifdef __cplusplus
}
#endif  /* __cplusplus */

#endif
